/**
 * 
 */
package com.thinkgsp.jxc.model;

import java.io.Serializable;
import java.lang.annotation.Inherited;
import java.math.BigDecimal;
import java.sql.Date;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.thinkgsp.util.XlsFieldAnnotation;
import com.thinkgsp.util.XlsValueType;

/**
 * 应收应付单据
 * @author evan
 *
 */
public class RpArpBill extends BaseModel implements RpBillCheck, Serializable {

	private static final long serialVersionUID = -2111220662673713247L;

	private Long arpBillId;
	@XlsFieldAnnotation(ChsName="单据编号",MethodName="getArpBillCode")
	private String arpBillCode;
	private Integer arpBillType;
	@XlsFieldAnnotation(ChsName="单据类型",MethodName="getArpBillName")
	private String arpBillName;
	@XlsFieldAnnotation(ChsName="单据日期",MethodName="getBillDate")
	private Date billDate = new Date(System.currentTimeMillis());
	
	private Date funcDate = new Date(System.currentTimeMillis());
	@XlsFieldAnnotation(ChsName="应付日期",MethodName="getArpDate")
	private Date arpDate = new Date(System.currentTimeMillis());
	private Integer direct;
	private Integer custSuppId;
	private Integer deptId;
	private Integer empId;
	private Integer makerId;
	@XlsFieldAnnotation(ChsName="金额",MethodName="getAmount")
	private BigDecimal amount = BigDecimal.ZERO;
	private Long jxcBillId;
	@XlsFieldAnnotation(ChsName="年份",MethodName="getFyear")
	private Integer fyear;
	@XlsFieldAnnotation(ChsName="期间",MethodName="getPeriod")
	private Integer period;
	private Boolean archived = false;
	
	
	@XlsFieldAnnotation(ChsName="核销金额",MethodName="getCheckAmount")
	private BigDecimal checkAmount = BigDecimal.ZERO;
	
	private BigDecimal currentCheckAmount = BigDecimal.ZERO;
	
	@XlsFieldAnnotation(ChsName="客户",MethodName="getCustomer",RefType=XlsValueType.RefClass)
	private Customer customer;
	
	@XlsFieldAnnotation(ChsName="部门",MethodName="getDept",RefType=XlsValueType.RefClass)
	private Dept dept;
	@XlsFieldAnnotation(ChsName="业务员",MethodName="getEmp",RefType=XlsValueType.RefClass)
	private Emp emp;
	@XlsFieldAnnotation(ChsName="制单",MethodName="getMaker",RefType=XlsValueType.RefClass)
	private Emp maker;
	@XlsFieldAnnotation(ChsName="备注",MethodName="getRemark")
	private String remark;
	private Integer checkStatus = 0;

	/**
	 * 核销金额,本属性从往来表读取
	 * @return
	 */
	public BigDecimal getCheckAmount() {
		return checkAmount;
	}

	/**
	 * 核销状态,本属性从往来表读取
	 * @return
	 */
	public Integer getCheckStatus() {
		return checkStatus;
	}

	public void setCheckAmount(BigDecimal checkAmount) {
		this.checkAmount = checkAmount;
	}

	public void setCheckStatus(Integer checkStatus) {
		this.checkStatus = checkStatus;
	}

	/**
	 * 客户供货商对象
	 * @return
	 */
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
		if(customer != null) {
			this.custSuppId = customer.getCustomerId();
		}
	}

	/**
	 * 部门
	 * @return
	 */
	public Dept getDept() {
		return dept;
	}

	public void setDept(Dept dept) {
		this.dept = dept;
		if(dept != null) {
			this.deptId = dept.getDeptId();
		}
	}

	/**
	 * 业务员
	 * @return
	 */
	public Emp getEmp() {
		return emp;
	}

	public void setEmp(Emp emp) {
		this.emp = emp;
		if(emp != null) {
			this.empId = emp.getEmpId();
		}
	}

	/**
	 * 制单人
	 * @return
	 */
	public Emp getMaker() {
		return maker;
	}

	public void setMaker(Emp maker) {
		this.maker = maker;
		if(maker != null) {
			this.makerId = maker.getEmpId();
		}
	}

	public BigDecimal getBillAmount() {
		return amount;
	}
	public BigDecimal getCurrentCheckAmount() {
		return currentCheckAmount;
	}
	public void setCurrentCheckAmount(BigDecimal currentCheckAmount) {
		this.currentCheckAmount = currentCheckAmount;
	}
	/**
	 * 获取未核销金额
	 * @return
	 */
	public BigDecimal getUnCheckAmount() {
		return amount.subtract(checkAmount);
	}

	public void setUnCheckAmount(BigDecimal unCheckAmount) {
		
	}
	/**
	 * 应收应付单据ID
	 * @return
	 */
	public Long getArpBillId() {
		return arpBillId;
	}

	public void setArpBillId(Long arpBillId) {
		this.arpBillId = arpBillId;
	}

	/**
	 * 应收应付单据编码
	 * @return
	 */
	public String getArpBillCode() {
		return arpBillCode;
	}

	public void setArpBillCode(String arpBillCode) {
		this.arpBillCode = arpBillCode;
	}

	/**
	 * 单据类型
	 * @return
	 */
	public Integer getArpBillType() {
		return arpBillType;
	}

	public void setArpBillType(Integer arpBillType) {
		this.arpBillType = arpBillType;
	}

	/**
	 * 单据名称
	 * @return
	 */
	public String getArpBillName() {
		return arpBillName;
	}

	public void setArpBillName(String arpBillName) {
		this.arpBillName = arpBillName;
	}

	/**
	 * 单据日期
	 * @return
	 */
	//@JsonSerialize(using=CustomerDateTimeSerializer.class)
	public Date getBillDate() {
		return billDate;
	}

	public void setBillDate(Date billDate) {
		this.billDate = billDate;
	}

	/**
	 * 财务日期
	 * @return
	 */
	//@JsonSerialize(using=CustomerDateTimeSerializer.class)
	public Date getFuncDate() {
		return funcDate;
	}

	public void setFuncDate(Date funcDate) {
		this.funcDate = funcDate;
	}

	/**
	 * 应收应付日期
	 * @return
	 */
	//@JsonSerialize(using=CustomerDateTimeSerializer.class)
	public Date getArpDate() {
		return arpDate;
	}

	public void setArpDate(Date arpDate) {
		this.arpDate = arpDate;
	}

	/**
	 * 应收应付方向(1 : 应收; -1 应付)
	 * @return
	 */
	public Integer getDirect() {
		return direct;
	}

	public void setDirect(Integer direct) {
		this.direct = direct;
	}

	/**
	 * 客户ID
	 * @return
	 */
	public Integer getCustSuppId() {
		return custSuppId;
	}

	public void setCustSuppId(Integer custSuppId) {
		this.custSuppId = custSuppId;
	}

	/**
	 * 部门ID
	 * @return
	 */
	public Integer getDeptId() {
		return deptId;
	}

	public void setDeptId(Integer deptId) {
		this.deptId = deptId;
	}

	/**
	 * 职员(业务员)
	 * @return
	 */
	public Integer getEmpId() {
		return empId;
	}

	public void setEmpId(Integer empId) {
		this.empId = empId;
	}

	/**
	 * 制单人
	 * @return
	 */
	public Integer getMakerId() {
		return makerId;
	}

	public void setMakerId(Integer makerId) {
		this.makerId = makerId;
	}

	/**
	 * 应收应付金额
	 * @return
	 */
	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	/**
	 * 出入库单据
	 * @return
	 */
	public Long getJxcBillId() {
		return jxcBillId;
	}

	public void setJxcBillId(Long jxcBillId) {
		this.jxcBillId = jxcBillId;
	}

	/**
	 * 年份
	 * @return
	 */
	public Integer getFyear() {
		return fyear;
	}

	public void setFyear(Integer fyear) {
		this.fyear = fyear;
	}

	/**
	 * 期间
	 * @return
	 */
	public Integer getPeriod() {
		return period;
	}

	public void setPeriod(Integer period) {
		this.period = period;
	}

	/**
	 * 归档标志(记账标志)
	 * @return
	 */
	public Boolean getArchived() {
		return archived;
	}

	public void setArchived(Boolean archived) {
		this.archived = archived;
	}
	public BigDecimal getCheckedAmount() {
		return checkAmount;
	}
	/**
	 * 备注
	 * @return
	 */
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#toString()
	 */
	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
		sb.append("arpBillId",this.arpBillId)
		  .append("amount",this.amount);
		
		return sb.toString();
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(!(o instanceof RpArpBill)) {
			return false;
		}
		final RpArpBill ab = (RpArpBill)o;
		if(arpBillId != null) {
			return arpBillId.equals(ab.getArpBillId());
		} else {
			return ab.getArpBillId() == null;
		}
	}

	/* (non-Javadoc)
	 * @see com.thinkgsp.jxc.model.BaseModel#hashCode()
	 */
	@Override
	public int hashCode() {
		return (this.arpBillId != null ? this.arpBillId.hashCode() : 0);
	}

}
